import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductTypeVO, ProductTypeForm, ProductTypeQuery } from '@/api/base/product/productType/types';

/**
 * 查询产品类型列表
 * @param query
 * @returns {*}
 */
export const listProductType = (query?: ProductTypeQuery): AxiosPromise<ProductTypeVO[]> => {
  return request({
    url: '/base/product/productType/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取产品信息列表
 * @param query
 * @returns {*}
 */
export const queryList = (query?: ProductTypeForm): AxiosPromise<ProductTypeForm[]> => {
  return request({
    url: '/base/product/productType/queryList',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品类型详细
 * @param id
 */
export const getProductType = (id: string | number): AxiosPromise<ProductTypeVO> => {
  return request({
    url: '/base/product/productType/' + id,
    method: 'get'
  });
};

/**
 * 新增产品类型
 * @param data
 */
export const addProductType = (data: ProductTypeForm) => {
  return request({
    url: '/base/product/productType',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品类型
 * @param data
 */
export const updateProductType = (data: ProductTypeForm) => {
  return request({
    url: '/base/product/productType',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品类型
 * @param id
 */
export const delProductType = (id: string | number | Array<string | number>) => {
  return request({
    url: '/base/product/productType/' + id,
    method: 'delete'
  });
};

export default {
  queryList
};
